/*
 * file_fd_ex_f.h
 *
 *  Created on: Jul 3, 2012
 *      Author: lucid
 */
#ifndef __FILE_FD_F_H__
#define __FILE_FD_F_H__


class filefdf_t
{
public:
	enum FILE_ACCESS_FLAG
	{
		FILE_ACCESS_FLAG_READ			= 0x00000001,
		FILE_ACCESS_FLAG_WRITE			= 0x00000002,
		FILE_ACCESS_FLAG_RDWR			= 0x00000003
	};

protected:
	FD_t m_fd;

public:
	static int is_exist(const char* chName);

	filefdf_t();
	virtual ~filefdf_t();

	operator FD_t()
	{
		return m_fd;
	}

	int create(const char* chName,U32 dwFlag);				//return error if exist
	int create_new(const char* chName,U32 dwFlag);	//create or open truncate to 0
	int open_exist(const char* chName,U32 dwFlag);			//return error if not exist
	int create_or_open(const char* chName,U32 dwFlag);	//create no truncate

	ssize_t write(U32 dwPos,const void* pData,U32 dwLen);
	ssize_t read(U32 dwPos,void* pData,U32 dwLen);
	int flush();
	int close();
	int set_len(U32 uLen);
	ssize_t get_len();
	ssize_t get_currpos();
};








#endif //__FILE_FD_F_H__
